package org.chupito.dao.impl;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TemporalType;
import javax.persistence.TypedQuery;

import org.chupito.data.Invoice;
import org.chupito.search.SearchObject;
import org.jboss.logging.Logger;

public class InvoiceDAO extends DAOImpl<Invoice> {

	@PersistenceContext
	private EntityManager em;

	public InvoiceDAO() {
	}

	public List<Invoice> find(SearchObject search) {

		String sql = "select t from Invoice t " + search.toWhere() ;
		
		Logger.getLogger(InvoiceDAO.class.getClass().getName()).info(sql);
		
		TypedQuery<Invoice> query = em.createQuery(sql, Invoice.class);		
		
		return query.getResultList();
	}
}
